package com.os.opencv.java.chapter2;

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class MatBatch {

    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        //创建矩阵mat
        Mat mat = new Mat(2, 2, CvType.CV_32SC3);
        System.out.println(mat.dump());

        //将矩阵数据放在数组data中
        int[] Data = new int[]{1, 2, 3, 4, 5, 6, 7, 8, 9, 128, 200, 255};
        mat.put(0, 0, Data);  //批量修改矩阵数据
        //查看矩阵数据
        System.out.println(mat.dump());

        //转换矩阵数据类型
        Mat m = new Mat();
        mat.convertTo(m, CvType.CV_8UC3);

        //获取矩阵的所有数据
        int[] i = new int[12];
        mat.get(0, 0, i);

        //查看m的矩阵头
        System.out.println(m);

        //查看矩阵数据
        System.out.println(m.dump());

        //查看数组i的数据
        for (int n=0; n<12; n++)
            System.out.print(i[n] + ",");
    }
}
